import QtQuick 2.15
import UIModule 1.0
Item {
    id:root
    property int radius : (width<height?width/2:height/2)*0.85
    property int seconds: (new Date).getSeconds()
    property bool h24: true
    property bool hideSecondEn: false
    Rectangle{
        anchors.fill: parent
        color:"#000000"
    }
    Path {
        id: myPath
        startX: root.width
        startY: root.height/2

        PathAngleArc {
            centerX: root.width/2
            centerY: root.height/2
            radiusX: root.radius    // 水平半径（椭圆时使用）
            radiusY: root.radius    // 垂直半径（椭圆时使用）
            startAngle: 0 // 起始角度（度）
            sweepAngle: 360 // 扫过角度（度）
            moveToStart: true // 是否移动到起点（默认为true）
        }

        // 闭合路径
       // PathLine { x: root.width/2; y: root.height/2 }
    }

    // 使用PathView显示沿路径移动的项目
    PathView {
        width: 400; height: 400
        model: 60
        delegate: Rectangle {
            width: root.radius/60
            height: (root.seconds === (index+15)%60 && hideSecondEn)?root.radius/8:root.radius/10
            radius: width/2
            rotation: 6*index+90
            color: UI.textColor
            opacity: root.seconds<(index+15)%60?0.2:1
        }
        path: myPath
    }
    Text{
        id:strItem
        anchors.centerIn: parent

        font.hintingPreference: Font.PreferVerticalHinting
        font.styleName: "Bold"
        font.bold: true
        font.pixelSize: root.radius/1.8
        anchors.horizontalCenter: parent.horizontalCenter
        horizontalAlignment: Text.AlignHCenter
        verticalAlignment:Text.AlignVCenter

        wrapMode: Text.WrapAnywhere
        renderType: Text.QtRendering

        text:(new Date).getHours().toString().padStart(2, '0')+":"+(new Date).getMinutes().toString().padStart(2, '0')
        color: UI.textColor
        clip:true
        antialiasing: true
    }
    Timer{
        id:timer
        repeat: true
        interval: 900
        running: true
        onTriggered: {
            var time = new Date
            var h = time.getHours()
            if(!UI.H24)  h = h>12?h-12:h
            strItem.text=h.toString().padStart(2, '0')+":"+time.getMinutes().toString().padStart(2, '0')
            root.seconds= time.getSeconds()
        }
    }
}
